<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改wip客户信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wipinfo-edit" th:object="${wipCusInfo}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="deptId"  type="hidden"  th:field="*{deptId}" id="treeId"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户编码：</label>
                <div class="col-sm-8">
                    <input name="customerCode" th:field="*{customerCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户名称：</label>
                <div class="col-sm-8">
                    <input name="customerName" th:field="*{customerName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">归属部门：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" id="treeName" th:field="*{dept.deptName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <label class="radio-box">
                        <input type="radio" value="0" id="ifConfirm1" name="status" th:checked="${ wipCusInfo.status == 0 ? true : false}">启用
                    </label>
                    <label class="radio-box">
                        <input type="radio" value="1" id="ifConfirm2" name="status" th:checked="${ wipCusInfo.status == 1 ? true : false}">停用
                    </label>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "wip/customer";
        $("#form-wipinfo-add").validate({
            onkeyup: false,
            rules:{
                customerCode:{
                    minlength: 2,
                    maxlength: 32
                },
                customerName:{
                    minlength: 2,
                    maxlength: 32
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-wipinfo-edit').serialize());
            }
        }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
            var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>